# Contributor: Thomas Böhler <witcher@wiredspace.de>
# Maintainer: Thomas Böhler <witcher@wiredspace.de>
pkgname=cocogitto
pkgver=6.1.0
pkgrel=0
pkgdesc="The Conventional Commits toolbox"
url="https://docs.cocogitto.io/"
arch="all"
license="MIT"
makedepends="cargo cargo-auditable"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/cocogitto/cocogitto/archive/refs/tags/$pkgver.tar.gz
	"
options="!check" # tests relies on, among other things, specific tags

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release

	local compgen="target/release/cog generate-completions"

	$compgen bash > cog.bash
	$compgen fish > cog.fish
	$compgen zsh > cog.zsh

	mkdir man
	target/release/cog generate-manpages man
}

package() {
	install -Dm755 -t "$pkgdir"/usr/bin target/release/cog

	install -Dm644 -t "$pkgdir"/usr/share/doc/"$pkgname" CHANGELOG.md
	install -Dm644 -t "$pkgdir"/usr/share/doc/"$pkgname" README.md

	install -Dm644 -t "$pkgdir"/usr/share/licenses/"$pkgname" LICENSE

	for i in man/*.1; do
		gzip "$i"
		install -Dm644 -t "$pkgdir"/usr/share/man/man1 "$i".gz
	done

	install -Dm644 cog.bash \
		"$pkgdir"/usr/share/bash-completion/completions/cog
	install -Dm644 cog.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/cog.fish
	install -Dm644 cog.bash \
		"$pkgdir"/usr/share/zsh/site-functions/_cog
}

sha512sums="
362d5fb3d976353bdd1b1bdae04c261865e7e5da44af68f591ee974c83aab54b827db6b50f1aa16ef362201fa04e595b8ffae9a6743b7505a3511fef6b4242f1  cocogitto-6.1.0.tar.gz
"
